import Vue from "vue"
import Vuex from "vuex"
import axios from "axios"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: {}
  },
  getters: {},
  mutations: {
    updateUserInfo(state, userInfo) {
      state.userInfo = userInfo
    }
  },
  actions: {
    async getUserInfo(ctx) {
      const { data: res } = await axios.get("/my/userinfo")
      ctx.commit("updateUserInfo", res.data)
    }
  },
  modules: {}
})
